package com.example.demo.services.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.port.fee.dao.AdminUserMapper;
import com.port.fee.entity.AdminUser;
import com.port.fee.service.AdminUserService;
import org.springframework.stereotype.Service;

/**
 * 管理员用户服务实现类
 */
@Service
public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser> implements AdminUserService {

    @Override
    public AdminUser login(String username, String password) {
        // 查询用户
        LambdaQueryWrapper<AdminUser> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AdminUser::getUsername, username);
        AdminUser adminUser = this.getOne(queryWrapper);
        
        // 验证密码（明文比较）
        if (adminUser != null && adminUser.getPassword().equals(password)) {
            // 安全起见，不返回密码
            adminUser.setPassword(null);
            return adminUser;
        }
        return null;
    }
} 